﻿Public Class ContextMenuItem

#Region "Properties"
    Public Property Text As String
        Get
            Return _Text
        End Get
        Set(value As String)
            _Text = value
            Title.Text = value
        End Set
    End Property
    Private _Text As String = "ContextMenuItem"

    Public Property ClickAction As Action

#End Region

    Public Event Clicked()

    Public Sub New()
        InitializeComponent()
    End Sub

    Public Sub New(ClickAction As Action)
        InitializeComponent()
        Me.ClickAction = ClickAction
    End Sub

    Private Sub ContextMenuItem_PreviewMouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs) Handles Me.PreviewMouseLeftButtonDown
        If Me.ClickAction IsNot Nothing Then Dispatcher.Invoke(Me.ClickAction)
        RaiseEvent Clicked()
    End Sub
End Class
